<template>
  <el-form class="form" label-width="70px">
    <el-form-item label="学科编号">
      <el-input v-model="params.rid" />
    </el-form-item>
    <el-form-item label="学科名称">
      <el-input v-model="params.name" />
    </el-form-item>
    <el-form-item label="创建者">
      <el-input v-model="params.username" />
    </el-form-item>
    <el-form-item label="状态">
      <el-select v-model="params.status" placeholder="请选择">
        <el-option label="启用" :value="1" />
        <el-option label="禁用" :value="0" />
      </el-select>
    </el-form-item>
    <template>
      <div class="btn">
        <el-button type="primary" @click="searchEvent">搜索</el-button>
        <el-button @click="delEvent">清除</el-button>
        <el-button type="primary" @click="addEvent">+新增学科</el-button>
      </div>
    </template>
    <add ref="add" @refresh="addEvent" />
  </el-form>
</template>

<script>
import Add from './add.vue'
export default {
  components: {
    Add
  },
  data() {
    return {
      params: {
        name: '', // 否	string	学科名称
        username: '', // 否	string	创建者用户名
        status: '', // 否	string	状态 0(禁用) 1(启用)
        page: 1, // 否	string	页码 默认为1
        limit: 10, // 否	string	页尺寸 默认为10
        rid: '' // 否	string	学科编号
      },
      dataForm: []
    }
  },
  methods: {
    addEvent() {
      this.$refs.add.isShow = true
      this.$refs.add.mode = 'add'
      this.$emit('refresh')
    },
    // 搜索
    async searchEvent() {
      const res = await this.$api.subject.subjectList(this.params)
      this.dataForm = res.data.items
      this.$emit('resresh2', this.dataForm)
    },
    // 清除
    delEvent() {
      this.params = {}
      this.$emit('refresh')
    }
  }
}
</script>

<style lang="scss" scoped>
.form {
  display: flex;
  .el-form-item {
    margin-right: 8px;
  }
  .btn {
    display: flex;
    height: 40px;
    margin-left: 10px;
  }
}
</style>
